home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / MISC.SWG / 0100_**APPENDING EXE**.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  1KB  |  61 lines

  1. {
  2. There's a problem here. You can append the binary data but that won't make
  3. code from both EXE files work. Either the first one will work, ignoring
  4. the code from the second one, or the whole thing will turn into trash.
  5.  
  6. However, if you still want to try it, go ahead. Here are 3 untested by
  7. compiling file copying programs that will only append IT2.EXE to the end of
  8. IT.EXE. You'll be required to make or copy files called IT.EXE and IT2.EXE
  9. for the use of this simple demonstration program.
  10. }
  11.  
  12. Program BCopy1;
  13. uses objects;
  14. var
  15.  f,f2:tdosstream;
  16. begin
  17.  f.init ('IT.EXE',stopen);
  18.  f.seek (f.getsize);
  19.  f2.init ('IT2.EXE',stopen);
  20.  f.copyfrom(f2,f2.getsize);
  21.  f.done;
  22.  f2.done;
  23. end.
  24.  
  25. Program BCopy2;
  26. var
  27.  f,f2:file;
  28.  blocks:longint;
  29.  bytes:word;
  30.  buffer:array [1..2048] of byte;
  31. begin
  32.  assign(f,'IT.EXE');
  33.  assign(f2,'IT2.EXE');
  34.  reset(f,1);
  35.  reset(f2,1);
  36.  seek(f,filesize(f));
  37.  bytes:=filesize(f2);
  38.  blocks:=bytes div 2048;
  39.  bytes:=bytes mod 2048;
  40.  while blocks>0 do begin
  41.   blockread(f2,buffer,sizeof(buffer));
  42.   blockwrite(f,buffer,sizeof(buffer));
  43.   dec(blocks);
  44.  end;
  45.  if bytes>0 then begin
  46.   blockread(f2,buffer,bytes);
  47.   blockwrite(f,buffer,bytes);
  48.  end;
  49.  close(f);
  50.  close(f2);
  51. end.
  52.  
  53. Program BCopy3;
  54. uses dos;
  55. begin
  56.  swapvectors;
  57.  exec(getenv('comspec'),'/c copy /b it.exe+it2.exe it.exe');
  58.  swapvectors;
  59. end.
  60.  
  61.